<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/12/22 0022
 * Time: 09:26
 */

class CommonAction extends Action {

    protected function buildSeo($chname, $datainfo=null, $catinfo=null)
    {
       $options=M("options")->where(array('optionname'=>'site_base'))->find();// "SELECT * FROM ".DB_PREFIX."options"
        if(!$options){die("请设置站点基本信息");}
        $site_base=$options["optionvalue"];
        $baseinfo=unserialize($site_base);
       //  dump($baseinfo);

        $seo_data = M("seo")->field("title, keyword, description")
            ->where(array("idmark" => $chname))->find();

        if (empty($seo_data))
        {
            die("没找到相关频道");
        }

        $seo_data['page_title'] = str_ireplace("{sitename}", $baseinfo['sitename'], $seo_data['title']);
        $seo_data['page_keyword'] = str_ireplace("{sitename}", $baseinfo['sitename'], $seo_data['keyword']);
        $seo_data['page_description'] = str_ireplace("{sitename}", $baseinfo['sitename'], $seo_data['description']);

        $seo_data["config"]=$baseinfo;
        //dump($seo_data);
        return $seo_data;


    }

}